<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="机器编号" prop="maccode">
        <el-input
          v-model="queryParams.maccode"
          placeholder="请输入机器编号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="品种编号" prop="pdfcode">
        <el-input
          v-model="queryParams.pdfcode"
          placeholder="请输入品种编号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="品种规格" prop="construction">
        <el-input
          v-model="queryParams.construction"
          placeholder="请输入织轴卡号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="织轴卡号" prop="shaftcode">
        <el-input
          v-model="queryParams.shaftcode"
          placeholder="请输入织轴卡号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="订单编号" prop="ordercode">
        <el-input
          v-model="queryParams.ordercode"
          placeholder="请输入订单编号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="班次日期" prop="shiftdate">
        <el-date-picker clearable size="small"
                        v-model="queryParams.shiftdate"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="选择班次日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="班次类型" prop="shifttype">
        <el-select v-model="queryParams.shifttype" placeholder="请选择班次类型" clearable size="small">
          <el-option
            v-for="dict in shifttypeOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="上机时间" prop="sjtime">
        <el-date-picker clearable size="small"
                        v-model="queryParams.sjtime"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="选择上机时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="了机时间" prop="ljtime">
        <el-date-picker clearable size="small"
                        v-model="queryParams.ljtime"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="选择了机时间">
        </el-date-picker>
      </el-form-item>

      <el-form-item label="操作员" prop="opworker">
        <el-select v-model="queryParams.opworker" placeholder="请选择操作员" clearable size="small">
          <el-option
            v-for="dict in opworkerOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <!--<el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          :loading="exportLoading"
          @click="handleExport"
          v-hasPermi="['mesana:size:export']"
        >导出
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>-->

    <el-table v-loading="loading" :data="sizeList">
      <el-table-column label="班次日期" align="center" prop="shiftdate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.shiftdate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="班次类别" align="center" prop="shifttype">
        <template slot-scope="scope">
          <dict-tag :options="shifttypeOptions" :value="scope.row.shifttype"/>
        </template>
      </el-table-column>
      <el-table-column label="机器编号" align="center" prop="maccode"/>
      <el-table-column label="轴号" align="center" prop="shaftcode"/>
      <el-table-column label="订单编号" align="center" prop="ordercode"/>
      <el-table-column label="品种编号" align="center" prop="pdfcode"/>
      <el-table-column label="品种规格" align="center" prop="construction" width="200"/>

      <el-table-column label="产地" align="center" prop="productArea"/>
      <el-table-column label="批次" align="center" prop="batchNo"/>
      <el-table-column label="色号" align="center" prop="colorNo"/>


      <el-table-column label="上机时间" align="center" prop="sjtime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.sjtime, '{y}-{m}-{d}  {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="了机时间" align="center" prop="ljtime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.ljtime, '{y}-{m}-{d}  {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>

      <!--<el-table-column label="操作员" align="center" prop="station"/>-->
     <!-- <el-table-column label="当前总长" align="center" prop="curlength"/>-->

      <el-table-column label="轴长(m)" align="center" prop="beamlength"/>
      <el-table-column label="设定总长(m)" align="center" prop="setlength"/>
      <el-table-column label="平均车速(m/min)" align="center" prop="avgSpeed"/>
      <el-table-column label="回潮率(%)" align="center" prop="regain"/>
      <el-table-column label="烘房温度1" align="center" prop="temp1"/>
      <el-table-column label="烘房温度2" align="center" prop="temp2"/>
      <el-table-column label="烘房温度3" align="center" prop="temp3"/>
      <el-table-column label="烘房温度4" align="center" prop="temp4"/>
      <el-table-column label="烘房温度5" align="center" prop="temp5"/>
      <el-table-column label="浆槽A温度" align="center" prop="tempa"/>
      <el-table-column label="浆槽B温度" align="center" prop="tempb"/>
      <el-table-column label="浆槽A压力" align="center" prop="pressurea"/>
      <el-table-column label="浆槽B压力" align="center" prop="pressureb"/>
      <el-table-column label="托纱辊压力" align="center" prop="pressuretuosha"/>
      <el-table-column label="ZA1张力" align="center" prop="tensionza1"/>
      <el-table-column label="ZB1张力" align="center" prop="tensionzb1"/>
      <el-table-column label="Z4张力" align="center" prop="tensionz4"/>
      <el-table-column label="Z5张力" align="center" prop="tensionz5"/>
      <el-table-column label="浆槽A液位" align="center" prop="yeweia"/>
      <el-table-column label="浆槽B液位" align="center" prop="yeweib"/>
      <el-table-column label="蜡槽1温度" align="center" prop="tempwax1"/>
      <el-table-column label="蜡槽2温度" align="center" prop="tempwax2"/>
      <el-table-column label="伸长Z2A" align="center" prop="stretchz2a"/>
      <el-table-column label="伸长Z3A" align="center" prop="stretchz3a"/>
      <el-table-column label="伸长Z2B" align="center" prop="stretchz2b"/>
      <el-table-column label="伸长Z3B" align="center" prop="stretchz3b"/>
      <el-table-column label="总伸长(%)" align="center" prop="stretchtotal"/>
      <el-table-column label="轴状态" align="center" prop="beamstatus">
        <template slot-scope="scope">
          <dict-tag :options="beamstatusOptions" :value="scope.row.beamstatus"/>
        </template>
      </el-table-column>
      <el-table-column label="操作员" align="center" prop="opworker">
        <template slot-scope="scope">
          <dict-tag :options="opworkerOptions" :value="scope.row.opworker"/>
        </template>
      </el-table-column>

      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['mesana:size:edit']"
          >修改
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['mesana:size:remove']"
          >删除
          </el-button>
        </template>
      </el-table-column>
      <el-table-column label="备注" align="center" prop="remark"/>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />


  </div>
</template>

<script>
    import {listSize, getSize, delSize, addSize, updateSize, exportSize} from "@/api/mesana/size";

    export default {
        name: "Size",
        data() {
            return {
                // 遮罩层
                loading: true,
                // 导出遮罩层
                exportLoading: false,
                // 选中数组
                ids: [],
                // 非单个禁用
                single: true,
                // 非多个禁用
                multiple: true,
                // 显示搜索条件
                showSearch: true,
                // 总条数
                total: 0,
                // 浆纱数据汇总表格数据
                sizeList: [],
                // 弹出层标题
                title: "",
                // 是否显示弹出层
                open: false,
                // 班次类型字典
                shifttypeOptions: [],
                // 是否跨班次字典
                iscrossshiftOptions: [],
                // 轴状态字典
                beamstatusOptions: [],
                // 操作员字典
                opworkerOptions: [],
                // 查询参数
                queryParams: {
                    pageNum: 1,
                    pageSize: 10,
                    maccode: null,
                    pdfcode: null,
                    shaftcode: null,
                    ordercode: null,
                    shiftdate: null,
                    shifttype: null,
                    sjtime: null,
                    ljtime: null,
                    beamstatus: 1,
                    opworker: null,
                    curlength: null,
                    beamlength: null,
                    setlength: null,
                    construction: null,

                },

            };
        },
        created() {
            this.getList();
            this.getDicts("dict_shiftType").then(response => {
                this.shifttypeOptions = response.data;
            });
            this.getDicts("dict_isCrossShift").then(response => {
                this.iscrossshiftOptions = response.data;
            });
            this.getDicts("dict_beamstatus").then(response => {
                this.beamstatusOptions = response.data;
            });
            this.getDicts("dict_sizeworkers").then(response => {
                this.opworkerOptions = response.data;
            });
        },
        methods: {
            /** 查询浆纱数据汇总列表 */
            getList() {
                this.loading = true;
                listSize(this.queryParams).then(response => {
                    this.sizeList = response.rows;
                    this.total = response.total;
                    this.loading = false;
                });
            },
            // 取消按钮
            cancel() {
                this.open = false;
                this.reset();
            },

            /** 搜索按钮操作 */
            handleQuery() {
                this.queryParams.pageNum = 1;
                this.getList();
            },
            /** 重置按钮操作 */
            resetQuery() {
                this.resetForm("queryForm");
                this.handleQuery();
            },
            // 多选框选中数据
            handleSelectionChange(selection) {
                this.ids = selection.map(item => item.id)
                this.single = selection.length !== 1
                this.multiple = !selection.length
            },


            /** 导出按钮操作 */
            handleExport() {
                const queryParams = this.queryParams;
                this.$confirm('是否确认导出所有浆纱数据汇总数据项?', "警告", {
                    confirmButtonText: "确定",
                    cancelButtonText: "取消",
                    type: "warning"
                }).then(() => {
                    this.exportLoading = true;
                    return exportSize(queryParams);
                }).then(response => {
                    this.download(response.msg);
                    this.exportLoading = false;
                }).catch(() => {
                });
            }
        }
    };
</script>
